<?php

namespace app\api\controller;

use app\common\controller\Frontend;
use app\api\model\Banner;
use app\api\model\DevicePlace as Place;
use think\facade\Db;

class Mpindex extends Frontend
{
    protected array $noNeedLogin = ['banner','place','notice','noticedetail'];
    public function banner()
    {
        if($this->request->isPost()){
            $banner = Banner::where('status',1)->select();
            $this->success('', $banner);
        }
    }

    public function place(){
       $list = Place::with('devices')->where('status',1)->limit(10)->select();
       $this->success('',$list,200);
    }
    public function notice(){
       $list =  Db::name('Notice')->where('status',1)->order('id desc')->limit(3)->field('title,id')->select();
       $this->success('',$list,200);
    }
    public function noticedetail(){
        $id = $this->request->param('id');
        $list =  Db::name('Notice')->where('id',$id)->find();
       $this->success('',$list,200);
    }

}